package com.sugon.util;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;

/**
 * 当验证规格不能满足需求时，使用自定义注解
 *
 * @author luoyuan
 * @create 2018-11-19-下午10:04
 */
@Documented
//自定义注解的实现类。
@Constraint(validatedBy = {ForbiddenValidator.class})
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE})
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(Forbidden.List.class)
public @interface Forbidden {

    //校验错误的默认信息
    String message() default "参数不正确";

    //分组
    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    @Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE})
    @Retention(RetentionPolicy.RUNTIME)
    @Documented
    @interface List {
        Forbidden[] value();
    }

    ;
}
